<?php
require_once('./config.php');
$service = new Amazon_SQS_Client(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY);

try {
	# Creating Queue if not present
	$queueRequest = array('QueueName' => $queueName);
	$queueResponse = $service->createQueue($queueRequest);
	if ($queueResponse->isSetCreateQueueResult()) { 
		$createQueueResult = $queueResponse->getCreateQueueResult();
		if ($createQueueResult->isSetQueueUrl()) {
			$queueUrl = $createQueueResult->getQueueUrl();
		}
	}
echo '<br> Queue Url : ' . $queueUrl;

// 	Queue message
	$ar = array();

	$messageRequest = array('QueueUrl' => $queueUrl, 'MessageBody' => json_encode($ar));
	$response = $service->sendMessage($messageRequest);
	if ($response->isSetSendMessageResult()) {
		$sendMessageResult = $response->getSendMessageResult();
		if ($sendMessageResult->isSetMessageId()) 
		{
			$imageCount++;
			echo '<br> Message Id : ' . $sendMessageResult->getMessageId();
		}
	}


} catch (Amazon_SQS_Exception $ex) {
	echo("Caught Exception: " . $ex->getMessage() . "\n<br>");
	echo("Response Status Code: " . $ex->getStatusCode() . "\n<br>");
	echo("Error Code: " . $ex->getErrorCode() . "\n<br>");
	echo("Error Type: " . $ex->getErrorType() . "\n<br>");
	echo("Request ID: " . $ex->getRequestId() . "\n<br>");
	echo("XML: " . $ex->getXML() . "\n<br>");
}

echo '<br><br> Total image messages sent : ' . $imageCount;

#-----------------------------


?>